package com.solution.admin.order.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.solution.admin.order.dao.OrderInvoiceDao;
import com.solution.admin.order.entity.OrderInvoiceEntity;
import com.solution.common.dao.impl.BaseDaoImpl;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;

/**
 * 订单发票信息DAO实现
 * @author lilp
 * @date 2017-09-18 19:24:52
 */
@Repository
public class OrderInvoiceDaoImpl extends BaseDaoImpl<OrderInvoiceEntity> implements OrderInvoiceDao {
	
	@Autowired
	SqlSessionTemplate sqlSessionTemplate;
	
	/**
	 * 获取客户最新的开票信息
	 * @param customerId 客户Id
	 * @return
	 * @author: solin
	 * @date: 2018年1月25日 下午9:33:32
	 */
	@Override
	public OrderInvoiceEntity getLatestByCustomerId(Long customerId) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("customerId", customerId);
		return this.sqlSessionTemplate.selectOne("getLatestByCustomerId", paramMap);
	}

	/**
	 * 保存订单发票信息信息
	 * @param orderInvoiceEntity
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:24:52
	 */
	@Override
	public long saveOrderInvoice(OrderInvoiceEntity orderInvoiceEntity) {
		return super.insert(orderInvoiceEntity);
	}

	/**
	 * 分页查询订单发票信息信息
	 * @param pageParam 分页对象
	 * @param orderInvoice 分页参数
	 * @return PageBean 分页参数及数据
	 * @author lilp
	 * @date 2017-09-18 19:24:52
	 */
	public PageBean listOrderInvoicePage(PageParam pageParam, Map<String, Object> param) {
		return super.listPage(pageParam, param);
	}

	/**
	 * 更新订单发票信息
	 * @param orderInvoiceEntity
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:24:52
	 */
	@Override
	public int updateOrderInvoice(OrderInvoiceEntity orderInvoiceEntity) {
		return super.update(orderInvoiceEntity);
	}

	/**
	 * 删除订单发票信息
	 * @param orderInvoiceId
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:24:52
	 */
	public int deleteOrderInvoiceById( Long id) {
		return super.deleteById(id);
	}
	
	/**
	 * 根据条件查询订单发票信息
	 * @param param
	 * @return
	 * @author lilp
	 * @date 2017-09-18 19:24:52
	 */
	@Override
	public List<OrderInvoiceEntity> listOrderInvoice( Map<String, Object> param) {
		return super.listBy(param);
	}
}
